package com.sunny.java8.function;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

/**
 * @author sunny
 * @date 2018/12/21
 */
public class FunctionTest {

    public static int multiplay(int a, Function<Integer, Integer> multy) {
        return multy.apply(a);
    }

    public static void main(String[] args) {
        int x = 5;
        System.out.println(multiplay(x, x1 -> x1 * 2 + 5));

        Consumer<String> consumer = a -> System.out.println(a + " -·····");
        consumer.accept("consumer");

        Supplier<String> supplier = () -> "给你了！";
        System.out.println(supplier.get());

        Predicate<Integer> pridicate = num -> num == 5;
        System.out.println(pridicate.test(5));
        System.out.println(pridicate.and(a -> a == 3));
    }
}
